package com.kangye.exam.service.serviceimpl;

import com.kangye.exam.bean.Subject;
import com.kangye.exam.dao.SubjectDao;
import com.kangye.exam.service.SubjectService;
import lombok.extern.log4j.Log4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service(value = "subjectService")
public class SubjectServiceImp implements SubjectService {

    @Resource
    private SubjectDao subjectDao;

    @Override
    public List<Subject> findAll() {
        return subjectDao.selectALL();
    }

    @Override
    public int delete(Integer id) {
        Map<String, Object> map = new HashMap<>();
        map.put("subjectId", id);
        return subjectDao.deleteByPrimaryKey(map);
    }

    @Override
    public Subject selectByID(Integer id) {
        Map<String, Object> map = new HashMap<>();
        map.put("subjectId", id);
        return subjectDao.selectByPrimaryKey(map);
    }

    @Override
    public int insert(Subject subject) {
        return subjectDao.insertSelective(subject);
    }

    @Override
    public int update(Subject subject) {
        return subjectDao.updateByPrimaryKeySelective(subject);
    }

    @Override
    public List<Subject> selectByParm(String subject) {
        Map<String, Object> map = new HashMap<>();
        map.put("subject", subject);
        return subjectDao.selectByParm(map);
    }
}
